# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=ibus
pkgver=1.5.25
pkgrel=1
pkgdesc="Next Generation Input Bus for Linux"
url="https://github.com/ibus/ibus/wiki"
arch="all"
license="LGPL-2.1-or-later"
depends="
	dconf hicolor-icon-theme iso-codes dbus py3-gobject3
"
makedepends="
	bash dconf-dev gtk+2.0-dev gtk+3.0-dev libnotify-dev iso-codes-dev
	gobject-introspection-dev vala intltool qt5-qtbase
	automake autoconf gnome-common gtk-doc wayland-dev wayland-protocols
	dbus-x11 unicode-character-database xz cldr-emoji-annotation
"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	$pkgname-emoji
	$pkgname-bash-completion:bashcomp:noarch
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/ibus/ibus/archive/$pkgver.tar.gz
	0001-Use-more-portable-call-to-mktemp.patch
	Fix-wrong-cursor-location-in-gtk3-apps.patch
"
install="$pkgname.post-install"

prepare() {
	# Fix all shebangs from 'python' to 'python3'
	grep -r -l '#!/usr/bin/python' . | xargs sed -i '1s|python|python3|'

	default_prepare
	NOCONFIGURE=1 ./autogen.sh
}

build() {
	./configure \
		--prefix=/usr \
		--libexecdir=/usr/lib/ibus \
		--sysconfdir=/etc \
		--enable-dconf \
		--enable-wayland \
		--disable-memconf \
		--enable-ui \
		--disable-gtk-doc \
		--enable-emoji-dict \
		--with-ucd-dir=/usr/share/unicode/
	make
}

check() {
	./bus/ibus-daemon --version
}

package() {
	make DESTDIR="$pkgdir" install
}

emoji() {
	pkgdesc="$pkgdesc (emojis)"
	depends="$pkgname unicode-character-database cldr-emoji-annotation"

	mkdir -p "$subpkgdir"/usr/share/ibus
	mv "$pkgdir"/usr/share/ibus/dicts "$subpkgdir"/usr/share/ibus
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	amove usr/share/bash-completion
}

sha512sums="
128373c6c35c7c8df02fa9e8e5458db6e38a35a7a7debf340c2b21d8e2ec803e3c95ed800211785b13b99210e1877322adb67ce47e5e9ef25e2734487af388fa  ibus-1.5.25.tar.gz
1e2e62ce52becf75d794c403e8f21bb72e8406aacbdbc5189f62a3b7c54166c40da0032d3f3865f5a23d9d2c782f974b7bcc9ba5ce437d9eb435dd3db3ff0b06  0001-Use-more-portable-call-to-mktemp.patch
426c261b79d1e6f57527edbc02f10ba01aefd444222638a370ed5213d9667624d608951845cd749ad6f4d6c7d2a17b7d1698147608b60edfb1a1be554fb00534  Fix-wrong-cursor-location-in-gtk3-apps.patch
"
